package com.firebird.app.fekpsl.ui.activity

import android.content.Intent
import android.view.WindowManager
import android.view.animation.AlphaAnimation
import android.view.animation.Animation
import com.firebird.app.fekpsl.R
import com.firebird.app.fekpsl.base.BaseActivity
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : BaseActivity() {

    private var alphaAnimation:AlphaAnimation?=null

    override fun attachLayoutRes(): Int = R.layout.activity_splash

    override fun useEventBus(): Boolean = false

    override fun enableNetworkTip(): Boolean =false

    override fun initData() {
    }

    override fun initView() {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        btn_start.setOnClickListener {
            fl_main.startScroll()
        }
        btn_stop.setOnClickListener {
            jumpToMain()
        }
        alphaAnimation= AlphaAnimation(0.3F,1.0F)
        alphaAnimation?.run {
            duration=2000
            setAnimationListener(object :Animation.AnimationListener{
                override fun onAnimationRepeat(animation: Animation?) {
                }

                override fun onAnimationEnd(animation: Animation?) {
                    jumpToMain()
                }

                override fun onAnimationStart(animation: Animation?) {
                }
            })
        }

    }

    override fun initColor() {
        super.initColor()
    }

    override fun start() {
    }

    fun jumpToMain() {
        val intent=Intent(this,MainActivity::class.java)
        startActivity(intent)
        finish()
        overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out)
    }
}
